/**
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package ro.uvt.sp.lp.hw1.beermugs.visual;

/**
 * 
 * @author LP
 *
 */
public class BeerMugState implements State {
	private int xWaterLevel;
	private int yWaterLevel;

	/**
	 * 
	 * @param x
	 * @param y
	 */
	public BeerMugState(int x, int y) {
		if (x < 0 || x > 3 || y < 0 || y > 4) {
			System.err.println("error, State");
		} else {
			xWaterLevel = x;
			yWaterLevel = y;
		}
	}

	/**
     * 
     */
	public BeerMugState() {
		xWaterLevel = 0;
		yWaterLevel = 0;
	}

	/**
     * 
     */
	public boolean equals(Object other) {
		BeerMugState anOther = (BeerMugState) other;

		return (this.getYLvl() == anOther.getYLvl() && this.getXLvl() == anOther
				.getXLvl());
	}

	/**
	 * reprezentare non gui pt o halba (mug)
	 */
	public String toString() {

		String xlvl1, xlvl2, xlvl3, xlvl4, ylvl1, ylvl2, ylvl3, ylvl4;
		xlvl1 = "       ";
		xlvl2 = "|   |  ";
		xlvl3 = "|   |  ";
		xlvl4 = "|   |  ";
		ylvl1 = "|   |\n";
		ylvl2 = "|   |\n";
		ylvl3 = "|   |\n";
		ylvl4 = "|   |\n";
		String lvlbot = "+---+  +---+\n" + "  X      Y  \n";

		switch (getXLvl()) {
		case (0):
			break;
		case (1):
			xlvl4 = "|***|  ";
			break;
		case (2):
			xlvl4 = "|***|  ";
			xlvl3 = "|***|  ";
			break;
		case (3):
			xlvl4 = "|***|  ";
			xlvl3 = "|***|  ";
			xlvl2 = "|***|  ";
			break;
		default:
			break;
		}

		switch (getYLvl()) {
		case (0):
			break;
		case (1):
			ylvl4 = "|***|\n";
			break;
		case (2):
			ylvl4 = "|***|\n";
			ylvl3 = "|***|\n";
			break;
		case (3):
			ylvl4 = "|***|\n";
			ylvl3 = "|***|\n";
			ylvl2 = "|***|\n";
			break;
		case (4):
			ylvl4 = "|***|\n";
			ylvl3 = "|***|\n";
			ylvl2 = "|***|\n";
			ylvl1 = "|***|\n";
			break;
		default:
			break;
		}
		String theString = xlvl1 + ylvl1 + xlvl2 + ylvl2 + xlvl3 + ylvl3
				+ xlvl4 + ylvl4 + lvlbot;
		return theString;
	}
	
	/**
	 * 
	 * @return
	 */
	public int getYLvl() {
		return yWaterLevel;
	}

	/**
	 * 
	 * @return
	 */
	public int getXLvl() {
		return xWaterLevel;
	}

}
